package zhuoer.adv1;

import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Digui {
	public static void a() {
		a();// 直接递归
	}

	public static long jiecheng(int k) {
		if (k <= 1)
			return 1L;

		return k * jiecheng(k - 1);
	}

	// 求斐波拉切 数列的第k项。前两项是1，后面的每一项等于前两项的和
	public static long feibo(int k) {
		if (k <= 2)
			return 1;
		return feibo(k - 1) + feibo(k - 2);
	}

	public static void main(String[] args) {
		// a();
		// long k = jiecheng(10);
		// System.out.println(k);
		// getAllFiles(new File("E:\\资料"));

		showAllFiles(new File("E:\\资料"));
	}

	private static void showAllFiles(File f) {
		LinkedList<File> fileList = new LinkedList<File>();
		fileList.add(f);

		while (fileList.size() > 0) {
			File file = fileList.removeFirst();

			System.out.println(file);
			File[] files = file.listFiles();
			for (File a : files) {
				System.out.println(a);
				if (a.isDirectory()) {
					fileList.addLast(a);
				}
			}
		}
	}

	private static void getAllFiles(File file) {
		// TODO Auto-generated method stub

		File[] files = file.listFiles();
		for (File a : files) {
			System.out.println(a);
			if (a.isDirectory()) {
				getAllFiles(a);
			}
		}

	}

}
